home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / disk / killDiskProcs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  3.2 KB  |  118 lines

  1. /*
  2.  *   $RCSfile: killDiskProcs.c,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:55:40 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37. #include "sysdefs.h"
  38. #include "ess.h"
  39. #include "checking.h"
  40. #include "trace.h"
  41. #include "error.h"
  42. #include "list.h"
  43. #include "tid.h"
  44. #include "io.h"
  45. #include "lock.h"
  46. #include "object.h"
  47. #include "msgdefs.h"
  48. #include "latch.h"
  49. #include "bitvec.h"
  50. #include "disk.h"
  51. #include "thread.h"
  52. #include "semaphore.h"
  53. #include "link.h"
  54. #include "bf.h"
  55. #include "pool.h"
  56. #include "volume.h"
  57. #include "disk_funcs.h"
  58. #include "io_globals.h"
  59. #include "io_extfuncs.h"
  60.  
  61. static BOOL
  62. killIt (
  63.     VOLREC *volRec
  64. )
  65. {
  66.     /* could be quiescing, in which case it won't have a diskrwPid */
  67.  
  68.     if(volRec->diskrwPid == 0) {
  69.         /* don't use an SM_ASSERT, because that will get us into
  70.          * an infinite loop
  71.          */
  72.         if(volRec->volflags & VOL_OPEN) {
  73.             fprintf(stderr, 
  74.             "ASSERTION ERROR @ line %d, file %s volume %d, fd=%d; exiting\n",
  75.             __LINE__,__FILE__, volRec->volid, volRec->queues->semNum);
  76.             exit(1);
  77.         }
  78.         return FALSE;
  79.     }
  80.  
  81. #ifdef DEBUG
  82.     fprintf(stderr, "killing DISKRW %d\n", volRec->diskrwPid);
  83. #endif DEBUG
  84.  
  85.     if(kill(volRec->diskrwPid, SIGINT)<0) { /* as if ^C used */
  86. #ifdef DEBUG
  87.         /* 
  88.          * If SIGINT were used to kill the server, the shell 
  89.          * also propogated it  to the disk processes, 
  90.          * in which case we'll get an ESRCH        
  91.          * Unfortunately, we don't know if we're now
  92.          * operating on behalf of a SIGINT or not.
  93.          */
  94.         if(errno != ESRCH) {
  95.             fprintf(stderr, "Couldn't kill child %d for volume %s.\n",
  96.                 volRec->diskrwPid, volRec->volNameRec->volName.name );
  97.             /* 
  98.              * do perror() so you don't get into infinite loop
  99.              * calling SM_Error()
  100.              */
  101.             perror("kill");
  102.         }
  103. #else DEBUG
  104.         /* oh well. */
  105. #endif DEBUG
  106.     }
  107.     return FALSE;
  108.  
  109. void
  110. killDiskProcs ( 
  111. )
  112. {
  113.     ForEachVolume(1, killIt, 0, 0, 0);
  114.     fprintf(stderr, "All disk processes  killed.\n");
  115. }
  116.  
  117.